#include <kapplication.h>
#include <kaboutdata.h>
#include <kcmdlineargs.h>
#include <KDE/KLocale>
#include <kurl.h>
#include "wormholetrayicon.h"
#include "snapshotmanager.h"
#include "clocktower.h"
#include <libwormhole/snapshot.h>
static const char description[] =
    I18N_NOOP("A KDE 4 Application");

static const char version[] = "0.1";
void fillClockTower(ClockTower *ct);
int main(int argc, char **argv)
{
    KAboutData about("wormholeserver", 0, ki18n("wormholeserver"), version, ki18n(description),
                     KAboutData::License_GPL, ki18n("(C) 2007 Diego Rosario Brogna"), KLocalizedString(), 0, "dierbro@gmail.com");
    about.addAuthor( ki18n("Diego Rosario Brogna"), KLocalizedString(), "dierbro@gmail.com" );
    KCmdLineArgs::init(argc, argv, &about);

    KCmdLineOptions options;
    options.add("+[URL]", ki18n( "Document to open" ));
    KCmdLineArgs::addCmdLineOptions(options);
    KApplication app;



    WormholeTrayIcon *systray = new WormholeTrayIcon;
SnapshotManager *sm=new SnapshotManager();
ClockTower *ct=new ClockTower(systray, sm);
fillClockTower(ct);
    // see if we are starting with session management
    if (app.isSessionRestored())
    {
      //  RESTORE(systray);
    }
    else
    {

        // no session.. just start up normally
        KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
        if (args->count() == 0)
        {
           systray->show();
        }
        else
        {
            int i = 0;
            for (; i < args->count(); i++)
            {
                systray->show();
            }
        }
        args->clear();
    }

    return app.exec();
}

void fillClockTower(ClockTower *ct)
{
Snapshot *test=new Snapshot();
test->setName("Snapshot1");
test->setBackendname("FakeBackend");
test->setBasedir(KUrl("/home/hrothgar"));
test->setDestdir(KUrl("/home/hrothgar"));

SnapshotSchedule *ss=new SnapshotSchedule(SnapshotSchedule::MINUTE);
ss->setCount(1);

test->setSnapshotschedule(ss);
ct->registerSnapshot(test);


Snapshot *test2=new Snapshot();
test2->setName("Snapshot2");
test2->setBackendname("FakeBackend");
test2->setBasedir(KUrl("/home/hrothgar"));
test2->setDestdir(KUrl("/home/hrothgar"));

SnapshotSchedule *ss2=new SnapshotSchedule(SnapshotSchedule::MINUTE);
ss2->setCount(2);

test2->setSnapshotschedule(ss2);
ct->registerSnapshot(test2);

}
